package ai.people.netmon.framework.typehandler;

import org.apache.ibatis.type.LocalDateTimeTypeHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.time.LocalDateTime;

/**
 * 我当地日期时间类型处理程序
 *
 * @author yuanqinglong
 * @date 2022/1/25 15:46
 */
public class MyLocalDateTimeTypeHandler extends LocalDateTimeTypeHandler {


    @Override
    public LocalDateTime getResult(ResultSet rs, String columnName) throws SQLException {
        Object object = rs.getObject(columnName);
        if (object instanceof Timestamp) {
            //return LocalDateTime.ofInstant(((Timestamp) object).toInstant(), ZoneOffset.ofHours(0));
            return ((Timestamp) object).toLocalDateTime();
        }
        return super.getResult(rs, columnName);
    }


}
